
include local.mk
# include arm.mk
# include aarch64.mk
# include ls3a4000.mk
# include ls3a5000.mk

ROOT = $(shell pwd)
INSTALL_PATH = $(ROOT)/libs

libs: libtool libsndfile pulseaudio
	@echo "=== Build pulseaudio for $(HOST) success ! ==="

help:
	@echo "HOST: $(HOST)" && \
	echo "CROSS: $(CROSS)" && \
	echo "CFLAGS: $(CFLAGS)" && \
	echo "INCS: $(INCS)" && \
	echo "LIBS: $(LIBS)"

PULSE_FLAGS += -lpulse-simple -lpulse -lpulsecore-14.2 -lpulsecommon-14.2
PULSE_FLAGS += -lpthread -ldl -lrt -lm

test:
	@$(CROSS)gcc -Wall -o out.test test.c \
		$(INCS) -I$(INSTALL_PATH)/include \
		$(LIBS) -L$(INSTALL_PATH)/lib -L$(INSTALL_PATH)/lib/pulseaudio \
		$(CFLAGS) $(PULSE_FLAGS)

test2:
	@$(CROSS)gcc -Wall -o out.test2 test2.c \
		$(INCS) -I$(INSTALL_PATH)/include \
		$(LIBS) -L$(INSTALL_PATH)/lib -L$(INSTALL_PATH)/lib/pulseaudio \
		$(CFLAGS) $(PULSE_FLAGS)

clean:
	@rm -rf out*

cleanall: clean
	@rm -rf $(INSTALL_PATH)/*

pulseaudio:
	@tar -xzf $(ROOT)/pkg/pulseaudio-14.2.tar.gz -C $(INSTALL_PATH) && \
	cd $(INSTALL_PATH)/pulseaudio-14.2 && \
	sed -i 's/ac_cv_lib_ltdl_lt_dladvise_init=no/ac_cv_lib_ltdl_lt_dladvise_init=yes/' ./configure && \
	./configure \
		--prefix=$(INSTALL_PATH) \
		--host=$(HOST) \
		CC=$(CROSS)gcc \
		CXX=$(CROSS)g++ \
		LDFLAGS="-L$(INSTALL_PATH)/lib -ldl $(LIBS) $(CFLAGS)" \
		CFLAGS="-I$(INSTALL_PATH)/include -ldl $(INCS) $(LIBS) $(CFLAGS)" \
		CPPFLAGS="-I$(INSTALL_PATH)/include -ldl $(INCS) $(LIBS) $(CFLAGS)" \
		PKG_CONFIG_PATH=$(INSTALL_PATH)/lib/pkgconfig \
		--with-pic \
		--with-xmlto=no \
		--with-fop=no \
		--with-database=simple \
		--without-caps \
		--without-soxr \
		--enable-ipv6 \
		--enable-shared=no \
		--enable-static \
		--enable-neon-opt=no \
		--disable-alsa \
		--disable-bluez5 \
		--disable-bluez5-ofono-headset \
		--disable-dbus \
		--disable-default-build-tests \
		--disable-dependency-tracking \
		--disable-doc \
		--disable-docs \
		--disable-documentation \
		--disable-glib2 \
		--disable-gsettings \
		--disable-gtk3 \
		--disable-gtk-doc \
		--disable-gtk-doc-html \
		--disable-jack \
		--disable-legacy-database-entry-format \
		--disable-manpages \
		--disable-nls \
		--disable-openssl \
		--disable-orc \
		--disable-running-from-build-tree \
		--disable-samplerate \
		--disable-udev \
		--disable-webrtc-aec \
		--disable-x11 && \
	make -j4 && make install && \
	cd - && \
	rm -rf $(INSTALL_PATH)/pulseaudio-14.2

libsndfile:
	@tar -xzf $(ROOT)/pkg/libsndfile-1.0.28.tar.gz -C $(INSTALL_PATH) && \
	cd $(INSTALL_PATH)/libsndfile-1.0.28 && \
	./configure \
		--prefix=$(INSTALL_PATH) \
		--host=$(HOST) \
		--with-pic \
		CC=$(CROSS)gcc \
		CXX=$(CROSS)g++ \
		LDFLAGS="$(LIBS) $(CFLAGS)" \
		CFLAGS="$(INCS) $(CFLAGS)" \
		CPPFLAGS="$(INCS) $(CFLAGS)" \
		--enable-shared=no \
		--enable-static=yes && \
	make -j4 && make install && \
	cd - && \
	rm -rf $(INSTALL_PATH)/libsndfile-1.0.28

libtool:
	@tar -xzf $(ROOT)/pkg/libtool-2.4.tar.gz -C $(INSTALL_PATH) && \
	cd $(INSTALL_PATH)/libtool-2.4 && \
	./configure \
		--prefix=$(INSTALL_PATH) \
		--host=$(HOST) \
		--with-pic \
		CC=$(CROSS)gcc \
		CXX=$(CROSS)g++ \
		LDFLAGS="$(LIBS) $(CFLAGS)" \
		CFLAGS="$(INCS) $(CFLAGS)" \
		CPPFLAGS="$(INCS) $(CFLAGS)" \
		--enable-static=yes \
		--enable-shared=no && \
	make -j4 && make install && \
	cd - && \
	rm -rf $(INSTALL_PATH)/libtool-2.4
